package code
{
	import flash.geom.Point;
	import flash.utils.Dictionary;
	
	/**
	 * ...
	 * @author Zachary "Giggles" Behrmann
	 */
	public class myLine
	{
		private var _point1:Point;
		private var _point2:Point;
		private var _adj:Vector.<myLine>;
		private var _adjSpawn:Vector.<spawnLine>;
		private var pointList:Dictionary;
		
		public function myLine(x1:int = 0, y1:int = 0, x2:int = 0, y2:int = 0, ... args)
		{
			pointList = new Dictionary(true);
			_point1 = new Point(x1, y1);
			_point2 = new Point(x2, y2);
			_adj = new Vector.<myLine>();
			for (var i:int = 0; i < args.length; i++)
			{
				_adj.push(args[i]);
			}
		}
		
		public function randomPoint(caller:Object, ... args):void
		{
			var objRestriction:Point;
			if (args.length == 1)
			{
				objRestriction = new Point(args[0], args[0]);
			}
			else if (args.length == 2)
			{
				objRestriction = new Point(args[0], args[1])
			}
			
			var x1:int;
			var x2:int;
			var y1:int;
			var y2:int;
			/*
			   if (_point1.x < _point2.x)
			   {
			   x1 = _point1.x + objRestriction.x;
			   x2 = _point2.x - objRestriction.x;
			   }
			   else
			   {
			   x2 = _point1.x - objRestriction.x;
			   x1 = _point2.x + objRestriction.x
			   }
			
			   if (_point1.y < _point2.y)
			   {
			   y1 = _point1.y + objRestriction.y;
			   y2 = _point2.y - objRestriction.y
			   }
			   else
			   {
			   y2 = _point1.y - objRestriction.y;
			   y1 = _point2.y + objRestriction.y
			   }
			
			   return new Point((x1 + (Math.random * (x2 - x1))), (y1 + (Math.random() * (y2 - y1))));
			 */
			if ((_point1.y - _point2.y) == 0)
			{
				if (_point1.x < _point2.x)
				{
					x1 = _point1.x + objRestriction.x;
					x2 = _point2.x - objRestriction.x;
				}
				else
				{
					x2 = _point1.x - objRestriction.x;
					x1 = _point2.x + objRestriction.x
				}
				pointList[caller] = new Point((x1 + (randoID * (x2 - x1))), y1);
			}
			else
			{
				if (_point1.y < _point2.y)
				{
					y1 = _point1.y + objRestriction.y;
					y2 = _point2.y - objRestriction.y
				}
				else
				{
					y2 = _point1.y - objRestriction.y;
					y1 = _point2.y + objRestriction.y
				}
				pointList[caller] = new Point(x1, (y1 + (randoID * (y2 - y1))));
			}
		}
		
		public function get point1():Point
		{
			return _point1;
		}
		
		public function get point2():Point
		{
			return _point2;
		}
		
		public function get adj():Vector.<myLine>
		{
			return _adj;
		
		}
		
		public function get adjSpawn():Vector.<myPoint>
		{
			return _adjSpawn;
		}
		
		public function set adjSpawn(value:Vector.<spawnLine>):void
		{
			_adjSpawn = value;
		}
		
		public function randoPoint(value:Object):Point
		{
			return pointList[value];
		}
	
	}

}